package com.yxy.mapper;

import com.github.pagehelper.Page;
import com.yxy.domain.dto.BannerPageQueryDTO;
import com.yxy.domain.po.Banner;
import com.yxy.domain.vo.BannerPageQueryVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface BannerMapper {
    /**
     * 添加轮播图
     * @param banner
     */
    void add(Banner banner);

    /**
     * 获取轮播图（用户端）
     * @return
     */
    @Select("select * from banner where status = 1")
    List<Banner> selectAll();

    /**
     * 分页查询
     * @param bannerPageQueryDTO
     * @return
     */
    @Select("select * from banner")
    Page<BannerPageQueryVO> page(BannerPageQueryDTO bannerPageQueryDTO);

    /**
     * 删除
     * @param id
     */
    @Delete("delete from banner where id = #{id}")
    void deleteById(int id);

    /**
     * 修改状态
     * @param id
     * @param status
     */
    @Update("update banner set status = #{status} where id = #{id}")
    void updateStatus(int id, int status);
}
